'use strict';
// 这里是用来获得编辑事件跳转页面时的数据的

let url = window.location.href

//// 因为我们跳转页面时加入了?id,所以我们可以根据?来将其分割然后取得id

let urlid = url.split['?']

let newdata
$(function () {



    $.get('http://localhost:8000/product', (data) => {
        newdata = data.filter(item => {
            return item.id == urlid[1]
        })
        console.log(newdata);


        if (urlid[1] != undefined) {


            $('#biaoti').val(newdata[0].biaoti)

            $('#zaiyao').val(newdata[0].zaiyao)

            $('#neirong').val(newdata[0], neirong)

            $('#fenlei').val(newdata[0], fenlei)

            $('#writer').val(newdata[0],writer)


            $('#datatime').val(newdata[0],datatime)

        }
    })

})


function yes() {

  


    let id = $('#id').val()

    let biaot = $('#biaoti').val()

    let zaiyao = $('#zaiyao').val()

    let neirong = $('#neirong').val()

    let fenlei = $('#fenlei').val()

    
    let writer = $('#writer').val()


    
    let datatime = $('#datatime').val()




    

let obj = {
    
    biaoti,
    zaiyao,
    neirong,
    fenlei,
    writer,
    datatime,
}

console.log(urlid[1]);


if (urlid[1]) {

    obj.id = urlid[1]

    noname(['edit', obj])
} else {
    noname(['add', obj])
}

}


